package com.mingmen.supplier.activity;


import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lzy.imagepicker.ImagePicker;
import com.mingmen.supplier.R;
import com.mingmen.supplier.adapter.AuditListAdapter;
import com.mingmen.supplier.adapter.CommodityLabelAdapter;
import com.mingmen.supplier.base.BaseBean;
import com.mingmen.supplier.defineview.GlideRoundTransform;
import com.mingmen.supplier.http.callback.StringCallback;
import com.mingmen.supplier.httpconfig.AppConfig;
import com.mingmen.supplier.httpconfig.HttpResponse;
import com.mingmen.supplier.immersionbar.ImmersionBar;
import com.mingmen.supplier.label.bean.LabelTestBean;
import com.mingmen.supplier.model.AuditDetailModel;
import com.mingmen.supplier.model.AuditListModel;
import com.mingmen.supplier.util.GsonUtil;
import com.mingmen.supplier.util.SharePreferenceUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Response;

public class AuditDetailActivity extends AppCompatActivity implements AuditListAdapter.OnItemClickListener {

    //返回按钮
    @BindView(R.id.text_return)
    TextView textReturn;

    String token;
    String commodityId;
    @BindView(R.id.commodityName)
    TextView commodityName;
    @BindView(R.id.description)
    TextView description;
    @BindView(R.id.category)
    TextView category;
    @BindView(R.id.commodityDetail)
    TextView commodityDetail;
    @BindView(R.id.linear_return)
    LinearLayout linear_return;
    @BindView(R.id.ivAvatar)
    ImageView ivAvatar;
    @BindView(R.id.ivAvatar_second)
    ImageView ivAvatar_second;

    Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail_audit);
        ButterKnife.bind(this);
        ImmersionBar.with(this)
                .statusBarDarkFont(true, 0.2f)
                .init();
        token = (String) SharePreferenceUtil.get(this, "token", "");
        commodityId = getIntent().getStringExtra("commodityId");
        Log.d("commodityId", commodityId);
        mContext=this;

        HttpResponse.getCommodityDetail(token, commodityId, new StringCallback(this) {
            @Override
            public void onSuccess(String s, Call call, Response response) {

                Log.d("getCommodityDetail",s);
                BaseBean baseBean = new BaseBean();
                baseBean = GsonUtil.GsonToBean(s, BaseBean.class);
                if (baseBean.getCode() == 0) {
                    AuditDetailModel auditDetailModel = new AuditDetailModel();
                    auditDetailModel = GsonUtil.GsonToBean(s, AuditDetailModel.class);
                    commodityName.setText(auditDetailModel.getData().getCommodityName());
                    description.setText(auditDetailModel.getData().getDescription());
                    commodityDetail.setText(auditDetailModel.getData().getCommodityDetail());
                    category.setText(auditDetailModel.getData().getCategory());

                   Log.d("PICURL",AppConfig.IMGURL+auditDetailModel.getData().getPicture());
                    Glide.with(AuditDetailActivity.this).load(AppConfig.IMGURL + auditDetailModel.getData().getPicture()).dontAnimate().placeholder(R.mipmap.zhanwei).error(R.mipmap.zhanwei).transform(new GlideRoundTransform(mContext, 5)).into(ivAvatar);
                    Glide.with(AuditDetailActivity.this).load(AppConfig.IMGURL + auditDetailModel.getData().getPicture()).dontAnimate().placeholder(R.mipmap.zhanwei).error(R.mipmap.zhanwei).transform(new GlideRoundTransform(mContext, 5)).into(ivAvatar_second);
                }

            }
        });


    }


    @OnClick({R.id.text_return, R.id.linear_return})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.text_return:
            case R.id.linear_return:
                finish();
                break;

        }
    }


    @Override
    public void onItemClickListener(View view, int pos, List<AuditListModel.DataBean> myLiveList) {

    }
}




